// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.randomizedWorld.randomizedVehicleStory;

import zombie.core.Rand;
import zombie.iso.IsoChunk;
import zombie.iso.IsoDirections;
import zombie.iso.IsoGridSquare;
import zombie.iso.IsoMetaGrid;
import zombie.iso.Vector2;
import zombie.vehicles.BaseVehicle;

public final class RVSCarCrashCorpse extends RandomizedVehicleStoryBase {
    public RVSCarCrashCorpse() {
        this.name = "Basic Car Crash Corpse";
        this.minZoneWidth = 6;
        this.minZoneHeight = 11;
        this.setChance(10);
    }

    @Override
    public void randomizeVehicleStory(IsoMetaGrid.Zone zone, IsoChunk chunk) {
        float _float = (float) (Math.PI / 6);
        this.callVehicleStorySpawner(zone, chunk, Rand.Next(-_float, _float));
    }

    @Override
    public boolean initVehicleStorySpawner(IsoMetaGrid.Zone zone, IsoChunk chunk, boolean debug) {
        VehicleStorySpawner vehicleStorySpawner = VehicleStorySpawner.getInstance();
        vehicleStorySpawner.clear();
        Vector2 vector2 = IsoDirections.N.ToVector();
        float _float = 2.5F;
        vehicleStorySpawner.addElement("vehicle1", 0.0F, _float, vector2.getDirection(), 2.0F, 5.0F);
        vehicleStorySpawner.addElement("corpse", 0.0F, _float - (float)(debug ? 7 : Rand.Next(4, 7)), vector2.getDirection() + (float) Math.PI, 1.0F, 2.0F);
        vehicleStorySpawner.setParameter("zone", zone);
        return true;
    }

    @Override
    public void spawnElement(VehicleStorySpawner spawner, VehicleStorySpawner.Element element) {
        IsoGridSquare isoGridSquare = element.square;
        if (isoGridSquare != null) {
            float _float = element.z;
            IsoMetaGrid.Zone zone = spawner.getParameter("zone", IsoMetaGrid.Zone.class);
            BaseVehicle baseVehicle = spawner.getParameter("vehicle1", BaseVehicle.class);
            String string = element.id;
            switch (string) {
                case "corpse":
                    if (baseVehicle != null) {
                        createRandomDeadBody(element.position.x, element.position.y, element.z, element.direction, false, 35, 30, null);
                        this.addTrailOfBlood(element.position.x, element.position.y, element.z, element.direction, 15);
                    }
                    break;
                case "vehicle1":
                    baseVehicle = this.addVehicle(zone, element.position.x, element.position.y, _float, element.direction, "bad", null, null, null);
                    if (baseVehicle != null) {
                        baseVehicle = baseVehicle.setSmashed("Front");
                        baseVehicle.setBloodIntensity("Front", 1.0F);
                        spawner.setParameter("vehicle1", baseVehicle);
                    }
            }
        }
    }
}
